package cn.coisini.api.admin;

import cn.coisini.model.common.dtos.Result;
import cn.coisini.model.common.enums.ResultEnum;
import cn.coisini.model.pojo.Role;
import cn.coisini.model.vo.RoleQueryVo;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author xiangshaw
 * Description: 角色接口API
 */
@Tag(name = "角色接口API", description = "一些关于角色的操作")
@RequestMapping("/api/v1/role")
public interface RoleControllerApi {

    @Operation(summary = "根据id查询角色")
    @GetMapping("/info/{id}")
    Result<Role> findRoleById(@PathVariable("id") String id);

    // 分页查询角色  当前页 - 每页记录数 - 查询对象
    @PreAuthorize("hasAuthority('role:list')")
    @Operation(summary = "条件分页查询")
    @GetMapping("/list")
    Result<Page<Role>> pagingQuery(RoleQueryVo roleQueryVo);

    @PreAuthorize("hasAuthority('role:add')")
    @Operation(summary = "添加角色")
    @PostMapping("/save")
    Result<ResultEnum> saveRole(@RequestBody Role role);

    @PreAuthorize("hasAuthority('role:update')")
    @Operation(summary = "修改角色")
    @PutMapping("/update")
    Result<ResultEnum> updateRole(@RequestBody Role role);

    @PreAuthorize("hasAuthority('role:remove')")
    @Operation(summary = "删除角色")
    @DeleteMapping("/remove/{id}")
    Result<Role> removeRole(@PathVariable("id") String id);

    @Operation(summary = "批量删除角色")
    @DeleteMapping("/batchRemove")
    Result<ResultEnum> batchRemoveRole(@RequestBody List<String> ids);
}
